package com.his.controller;


import com.his.entity.NonDrug;
import com.his.entity.NonDrugItemRecord;
import com.his.entity.Registration;
import com.his.entity.ResponseResult;
import com.his.service.INonDrugItemRecordService;
import com.his.service.INonDrugService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 检查项检验项处置项记录表(开立的) 前端控制器
 * </p>
 *
 * @author Demoon Liu
 * @since 2022-02-20
 */
@RestController
@RequestMapping("/non-drug-item-record")
@Tag(name = "非药品项目管理以及医技工作台模块接口")
public class NonDrugItemRecordController {
    @Resource
    private INonDrugItemRecordService service;
    @Resource
    private INonDrugItemRecordService iNonDrugItemRecordService;

    @PostMapping("insert")
    @Operation(summary = "新增非药品项目", description = "至少需要registrationid，nodrugid，checkparts")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "201", description = "返回201，插入成功"),
            @ApiResponse(responseCode = "400", description = "返回400，插入失败"),
    })
    public ResponseResult insert(@RequestBody NonDrugItemRecord nonDrugItemRecord) {
        return service.myInsert(nonDrugItemRecord);
    }

    @PostMapping("update")
    @Operation(summary = "根据id更新非药品项目信息", description = "id是必要参数")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "201", description = "返回201，更新成功"),
            @ApiResponse(responseCode = "400", description = "返回400，更新失败"),
    })
    public ResponseResult update(@RequestBody NonDrugItemRecord nonDrugItemRecord) {
        return service.myUpdate(nonDrugItemRecord);
    }

    @PostMapping("delete")
    @Operation(summary = "根据id删除非药品项目信息", description = "id是必要参数")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "201", description = "返回201，删除成功"),
            @ApiResponse(responseCode = "400", description = "返回400，删除失败"),
    })
    public ResponseResult delete(@RequestBody NonDrugItemRecord nonDrugItemRecord) {
        return service.myDelete(nonDrugItemRecord);
    }

    //尚峰
    @PostMapping("/record/query")
    @Operation(summary = "根据科室id查询未检查患者", description = "输入科室id，返回未检查患者")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "查询成功"),
            @ApiResponse(responseCode = "250", description = "查询失败"),
    })
    public ResponseResult selectPatientById(@RequestBody Registration registration){
        return iNonDrugItemRecordService.selectPatientById(registration);
    }

    @PostMapping("/record/query1")
    @Operation(summary = "查询全部检查记录", description = "返回全部检查记录")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "查询成功"),
            @ApiResponse(responseCode = "250", description = "查询失败"),
    })
    public ResponseResult selectAllRecord(){
        return iNonDrugItemRecordService.selectAllRecord();
    }

    @PostMapping("/record/update")
    @Operation(summary = "根据门诊号上传检查结果", description = "输入门诊号，更新checkresult和resultimgurllist")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "更新成功"),
            @ApiResponse(responseCode = "250", description = "更新失败"),
    })
    public ResponseResult updateRecord(@RequestBody NonDrugItemRecord nonDrugItemRecord){
        return iNonDrugItemRecordService.updateRecord(nonDrugItemRecord);
    }

    @PostMapping("/record/insert")
    @Operation(summary = "新增检查记录", description = "除了Createtime，Logdatetime和Excutetime，都需要插入")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "插入成功"),
            @ApiResponse(responseCode = "250", description = "插入失败"),
    })
    public ResponseResult insertRecord(@RequestBody NonDrugItemRecord nonDrugItemRecord){
        return iNonDrugItemRecordService.insertRecord(nonDrugItemRecord);
    }

}
